
<#--包名-->
package ${mapperBean.controllerPackagePath};

<#--bean的包路径-->
import ${mapperBean.beanPackagePath}.${mapperBean.beanName};
<#--引入接口-->
import ${mapperBean.servicePackagePath}.${mapperBean.serviceClassName};

import cn.chinaunicom.sdsi.frm.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.json.JSONObject;

/**
 * @author ${bean.createUser}
 * ${.now}
 *
 */

@Controller
@RequestMapping("${mapperBean.controllerClassName?uncap_first}")
public class ${mapperBean.controllerClassName?cap_first} extends BaseController{

	private final Log log = LogFactory.getLog(${mapperBean.controllerClassName?cap_first}.class);
	
	<#--注入接口-->
	@Autowired
	private ${mapperBean.serviceClassName} ${mapperBean.serviceClassName?uncap_first};

	/**
	 * 跳转至查询页面
	 */
	@RequestMapping("/${mapperBean.controllerClassName?uncap_first}Main")
	public ModelAndView ${mapperBean.controllerClassName?uncap_first}Main(ModelAndView mv){
		log.debug("${mapperBean.controllerClassName?cap_first}.${mapperBean.controllerClassName?uncap_first}Main{}");
		mv.setViewName("${bean.jspPath}/${mapperBean.jspListName}");
		return mv;
	}
	
	/**
	 * 跳转至新增页面
	 */
	@RequestMapping("/showAddPage")
	public ModelAndView showAddPage(ModelAndView mv){
		mv.setViewName("${bean.jspPath}/${mapperBean.jspAddName}");
		return mv;
	}
	
	/**
	 * 分页查询
	 * @param start 开始条数,名称不可改变，参数为分页组件传入
	 * @param length 每页大小,名称不可改变，参数为分页组件传入
	 */
	@ResponseBody
	@RequestMapping("/search4PageList")
	public JSONObject search4PageList(${mapperBean.beanName} ${mapperBean.beanName?uncap_first},Integer start, Integer length){
		
		log.debug("${mapperBean.controllerClassName?cap_first}.search4PageList{}");
		return ${mapperBean.serviceClassName?uncap_first}.search4PageList(${mapperBean.beanName?uncap_first},start,length);
	}
	
	/**
	 * 查询单条数据
	 */
	@RequestMapping("/selectByPrimaryKey")
	public ModelAndView selectByPrimaryKey(${mapperBean.beanName} ${mapperBean.beanName?uncap_first},ModelAndView mv){
		
		log.debug("${mapperBean.controllerClassName?cap_first}.selectByPrimaryKey{}");
		${mapperBean.beanName} bean=${mapperBean.serviceClassName?uncap_first}.selectByPrimaryKey(${mapperBean.beanName?uncap_first});
		mv.addObject("bean",bean);
		mv.setViewName("${bean.jspPath}/${mapperBean.jspUpdateName}");
		return mv;
	}
	
	/**
	 * 删除单条数据
	 */
	@ResponseBody
	@RequestMapping("/deleteByPrimaryKey")
	public int deleteByPrimaryKey(${mapperBean.beanName} ${mapperBean.beanName?uncap_first}){
		int delnum = ${mapperBean.serviceClassName?uncap_first}.deleteByPrimaryKey(${mapperBean.beanName?uncap_first});
		return delnum;
	}

	/**
	 * 保存数据
	 */
	@ResponseBody
	@RequestMapping("/addObject")
	public int addObject(${mapperBean.beanName} ${mapperBean.beanName?uncap_first}){
		int insertnum = ${mapperBean.serviceClassName?uncap_first}.addObject(${mapperBean.beanName?uncap_first});
		return insertnum;
	}

	/**
	 * 修改单条数据
	 */
	@ResponseBody
	@RequestMapping("/updateByPrimaryKey")
	public int updateByPrimaryKey(${mapperBean.beanName} ${mapperBean.beanName?uncap_first}){
		int updatetnum = ${mapperBean.serviceClassName?uncap_first}.updateByPrimaryKey(${mapperBean.beanName?uncap_first});
		return updatetnum;
	}
}